home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / instal.zip / WSLIB / SULIB.H < prev    next >
C/C++ Source or Header  |  1991-06-12  |  12KB  |  282 lines

  1. /*
  2.  * SULIB.H - Windows Setup
  3.  *
  4.  */
  5.  
  6. /*  macros used to define functions:
  7.  *
  8.  *    EXPORT        - This function can be called from external to this DLL
  9.  *    PUBLIC        - This function can be called from another file
  10.  *    PRIVATE     - This function can only be called from inside this file
  11.  *
  12.  *  eg      int EXPORT foo();
  13.  *
  14.  * CEXPORT, CPUBLIC, and CPRIVATE are the same but use CDECL calling convention.
  15.  */
  16. #ifndef EXPORT
  17.     #define EXPORT          FAR  PASCAL
  18.     #define PUBLIC          FAR  PASCAL
  19.     #define PRIVATE         NEAR PASCAL
  20.     #define CEXPORT         FAR  cdecl
  21.     #define CPUBLIC         FAR  cdecl
  22.     #define CPRIVATE        NEAR cdecl
  23. #endif
  24.  
  25.  
  26. #define FAR_HEAP
  27.  
  28. #define FALLOC(n)                (VOID FAR *)MAKELONG(0, GlobalAlloc(GPTR, (DWORD)n))
  29. #define FFREE(n)                 GlobalFree((HANDLE)HIWORD((LONG)n))
  30.  
  31. #define FOPEN(sz)                _lopen(sz,READ)
  32. #define FCREATE(sz)              _lcreat(sz,0)
  33. #define FCLOSE(fh)               _lclose(fh)
  34. #define FREAD(fh,buf,len)        _lread(fh,buf,len)
  35. #define FWRITE(fh,buf,len)       _lwrite(fh,buf,len)
  36. #define FSEEK(fh,off,i)          _llseek(fh,(DWORD)off,i)
  37.  
  38. #define FERROR()                 0
  39.  
  40. #define ALLOC(n)                 (VOID *)LocalAlloc(LPTR,n)
  41. #define FREE(p)                  LocalFree(p)
  42. #define SIZE(p)                  LocalSize(p)
  43. #define REALLOC(p,n)             LocalRealloc(p,n,LMEM_MOVEABLE)
  44.  
  45.  
  46. /* flags for _lseek */
  47. #define  SEEK_CUR 1
  48. #define  SEEK_END 2
  49. #define  SEEK_SET 0
  50.  
  51.  
  52. #define MAXPATHLEN           65       /* path length max + Null Byte */
  53. #define MAXFILESPECLEN       67       /* drive: + path length max + Null Byte */
  54. #define MAXCMDLINELEN        128      /* Maximum length of DOS command line */
  55. #define FILEMAX              14       /* 8.3 + NULL byte */
  56. #define MAX_INF_LINE_LEN     150      /* Maximum length of any .inf line */
  57. #define MAX_SYS_INF_LEN      16       /* ##: + 8.3 + NULL */
  58. #define MAX_PROF_LINE_LEN    15       /* Mamimum length of any profile string */
  59. #define MAX_ASPECT_STR_LEN   11       /* Max length of aspect ratio string */
  60. #define MAX_VDD_LEN          75       /* multiple vdd names, vdd,vdd,vdd ect. */
  61. #define MAX_SECT_NAME_LEN    20       /* Max length of a section Name. */
  62. #define MAXSTR               128
  63.  
  64. #define CNT_Z        0x1A
  65. #define ISEOF(c)     ((c) == '\0' || (c) == CNT_Z)
  66. #define ISSEP(c)     ((c) == '='  || (c) == ',')
  67. #define ISWHITE(c)   ((c) == ' '  || (c) == '\t' || (c) == '\n' || (c) == '\r')
  68. #define ISFILL(c)    ((c) == ' '  || (c) == '\t')
  69. #define ISEOL(c)     ((c) == '\n' || (c) == '\r' || (c) == '\0' || (c) == CNT_Z)
  70. #define ISCRLF(c)    ((c) == '\n' || (c) == '\r')
  71. #define ISNOISE(c)   ((c) == '"')
  72. #define ISDIGIT(c)   ((c) >= '0' && (c) <= '9')
  73. #define ISHEX(c)     (ISDIGIT(c) || ISCHAR(c))
  74. #define ISCHAR(c)    (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
  75. #define SLASH(c)     ((c) == '/' || (c) == '\\')
  76. #define DEVICESEP(c) ((c) == '/' || (c) == '\\' || (c) == '=' || (c) == ' ' || (c) == '\t')
  77. #define UP_CASE(c)   ((c) | 0x20)  // this is lower case !
  78. #define UPCASE(c)    ((c) & 0xdf)  // real upcase.
  79. #define HEXVAL(c)    (ISDIGIT(c) ? (c) - '0' : UP_CASE(c) - 'a' + 10)
  80. #define CHDISK(n)    (char)((n) < 10 ? '0' + (char)(n) : 'A' + (char)((n) - 10))
  81.  
  82. #define CHSEPSTR                "\\"
  83. #define EQUAL                   '='
  84. #define SPACE                   ' '
  85. #define LF                      0x0A
  86. #define CR                      0x0D
  87.  
  88. /*
  89.  *  directory or file name where SETUP.INF can be found.
  90.  */
  91. char szSetupInf[MAXPATHLEN];
  92.  
  93. /*
  94.  *  directory where windows will be setup to
  95.  */
  96. char szSetupPath[MAXPATHLEN];
  97.  
  98. /*
  99.  *  directory where the root of the setup disks are!
  100.  */
  101. char szDiskPath[MAXPATHLEN];
  102.  
  103. typedef LPSTR    PINF;
  104.  
  105. extern PINF PUBLIC infOpen(PSTR szInf);
  106. extern void PUBLIC infClose(PINF pinf);
  107. extern PINF PUBLIC infSetDefault(PINF pinf);
  108. extern PINF PUBLIC infFindSection(PINF pinf, PSTR szSection);
  109. extern BOOL PUBLIC infGetProfileString(PINF pinf, PSTR szSection, PSTR szItem,LPSTR szBuf);
  110. extern BOOL PUBLIC infParseField(PINF szData, int n, LPSTR szBuf);
  111. extern PINF PUBLIC infNextLine(PINF pinf);
  112. extern int  PUBLIC infLineCount(PINF pinf);
  113. extern BOOL PUBLIC infLookup(PSTR szInf, LPSTR szBuf);
  114.  
  115. /* TYPEDEFS - copy.c */
  116. typedef BOOL (PUBLIC    *FPFNCOPY) (int,int,LPSTR);
  117. #define COPY_ERROR          0x0001
  118. #define COPY_STATUS         0x0002
  119. #define COPY_INSERTDISK     0x0003
  120. #define COPY_QUERYCOPY      0x0004
  121. #define COPY_START          0x0005
  122. #define COPY_END            0x0006
  123.  
  124. extern WORD PUBLIC FileCopy (LPSTR szSource, PSTR szDir, FPFNCOPY fpfnCopy, WORD fCopy);
  125.  
  126. #define FC_FILE      0x0000
  127. #define FC_LIST      0x0001
  128. #define FC_SECTION   0x0002
  129. #define FC_LSTPTR    0x0004
  130. #define FC_QUALIFIED 0x0008
  131. #define FC_DEST_QUALIFIED 0x0010
  132.  
  133. #define FC_ABORT    0
  134. #define FC_IGNORE   1
  135. #define FC_RETRY    2
  136.  
  137. /* External functions from copy.c */
  138.  
  139. extern void PUBLIC fartonear(LPSTR dst, LPSTR src);
  140. extern BOOL PUBLIC ExpandFileName(PSTR szFile, PSTR szPath);
  141. extern int  NEAR       DosCopy(PSTR szFile, PSTR szPath);
  142. extern void PUBLIC catpath(PSTR path, PSTR sz);
  143. extern PSTR PUBLIC FileName(PSTR szPath);
  144. extern PSTR PUBLIC StripPathName(PSTR szPath);
  145.  
  146. /* TYPEDEFS - dos.asm */
  147.  
  148. #define ATTR_READONLY   0x0001
  149. #define ATTR_HIDDEN     0x0002
  150. #define ATTR_SYSTEM     0x0004
  151. #define ATTR_VOLUME     0x0008
  152. #define ATTR_DIR        0x0010
  153. #define ATTR_ARCHIVE    0x0020
  154. #define ATTR_FILES      (ATTR_READONLY+ATTR_SYSTEM)
  155. #define ATTR_ALL_FILES  (ATTR_READONLY+ATTR_SYSTEM+ATTR_HIDDEN)
  156. #define ATTR_ALL        (ATTR_READONLY+ATTR_DIR+ATTR_HIDDEN+ATTR_SYSTEM)
  157.  
  158. typedef struct {
  159.     char        Reserved[21];
  160.     BYTE        Attr;
  161.     WORD        Time;
  162.     WORD        Date;
  163.     DWORD       Length;
  164.     char        szName[13];
  165. }   FCB;
  166.  
  167. typedef FCB     * PFCB;
  168. typedef FCB FAR * LPFCB;
  169.  
  170. /* functions from dos.asm */
  171.  
  172. extern int   PUBLIC DosFindFirst (LPFCB lpfcb, LPSTR szFileSpec, WORD attr);
  173. extern int   PUBLIC DosFindNext  (LPFCB lpfcb);
  174. extern int   PUBLIC GetCurrentDrive (void);
  175. extern int   PUBLIC SetCurrentDrive (int iDrive);
  176. extern LONG  PUBLIC DosDiskFreeSpace(int iDrive);
  177. extern int   PUBLIC DosCwd   (LPSTR szDir);
  178. extern int   PUBLIC DosChDir (LPSTR szDir);
  179. extern int   PUBLIC DosMkDir (LPSTR szDir);
  180. extern int   PUBLIC DosValidDir (LPSTR szDir);
  181. extern int   PUBLIC GetFixedDisks(int * rgiDrive);
  182. extern int   PUBLIC GetCurrentVolume (LPSTR szBuf);
  183. extern int   PUBLIC DosRemoveable(int iDisk);
  184. extern int   PUBLIC DosIsRemote(int);
  185. extern int   PUBLIC MyReadWriteSector(void far *, int, int, int, int, int);
  186. extern DWORD PUBLIC DosMemory(void);
  187. extern int   PUBLIC DosRename(LPSTR, LPSTR);
  188. extern int   PUBLIC DosDelete(LPSTR);
  189. extern WORD  PUBLIC DosVersion(void);
  190. extern void  PUBLIC DosExit(WORD);
  191. extern LPSTR PUBLIC DosGetEnv(void);
  192. extern DWORD PUBLIC XmsVersion(void);
  193. extern BOOL  PUBLIC XmsInstalled(void);
  194. extern void  PUBLIC Reboot(void);
  195. extern int   PUBLIC GetCodePage(void);
  196. extern WORD  PUBLIC get_ext(void);
  197. extern WORD  PUBLIC ExtendedMemory(void);
  198. extern void  PUBLIC fnGetFilePath(char*, char*);
  199.  
  200. /* DOS ERROR CODES */
  201.  
  202. #define ERROR_OK            0x00
  203. #define ERROR_FILENOTFOUND  0x02    /* File not found */
  204. #define ERROR_PATHNOTFOUND  0x03    /* Path not found */
  205. #define ERROR_NOFILEHANDLES 0x04    /* Too many open files */
  206. #define ERROR_ACCESSDENIED  0x05    /* Access denied */
  207. #define ERROR_INVALIDHANDLE 0x06    /* Handle invalid */
  208. #define ERROR_FCBNUKED      0x07    /* Memory control blocks destroyed */
  209. #define ERROR_NOMEMORY      0x08    /* Insufficient memory */
  210. #define ERROR_FCBINVALID    0x09    /* Memory block address invalid */
  211. #define ERROR_ENVINVALID    0x0A    /* Environment invalid */
  212. #define ERROR_FORMATBAD     0x0B    /* Format invalid */
  213. #define ERROR_ACCESSCODEBAD 0x0C    /* Access code invalid */
  214. #define ERROR_DATAINVALID   0x0D    /* Data invalid */
  215. #define ERROR_UNKNOWNUNIT   0x0E    /* Unknown unit */
  216. #define ERROR_DISKINVALID   0x0F    /* Disk drive invalid */
  217. #define ERROR_RMCHDIR       0x10    /* Attempted to remove current directory */
  218. #define ERROR_NOSAMEDEV     0x11    /* Not same device */
  219. #define ERROR_NOFILES       0x12    /* No more files */
  220. #define ERROR_13            0x13    /* Write-protected disk */
  221. #define ERROR_14            0x14    /* Unknown unit */
  222. #define ERROR_15            0x15    /* Drive not ready */
  223. #define ERROR_16            0x16    /* Unknown command */
  224. #define ERROR_17            0x17    /* Data error (CRC) */
  225. #define ERROR_18            0x18    /* Bad request-structure length */
  226. #define ERROR_19            0x19    /* Seek error */
  227. #define ERROR_1A            0x1A    /* Unknown media type */
  228. #define ERROR_1B            0x1B    /* Sector not found */
  229. #define ERROR_WRITE         0x1D    /* Write fault */
  230. #define ERROR_1C            0x1C    /* Printer out of paper */
  231. #define ERROR_READ          0x1E    /* Read fault */
  232. #define ERROR_1F            0x1F    /* General failure */
  233. #define ERROR_SHARE         0x20    /* Sharing violation */
  234. #define ERROR_21            0x21    /* File-lock violation */
  235. #define ERROR_22            0x22    /* Disk change invalid */
  236. #define ERROR_23            0x23    /* FCB unavailable */
  237. #define ERROR_24            0x24    /* Sharing buffer exceeded */
  238. #define ERROR_32            0x32    /* Unsupported network request */
  239. #define ERROR_33            0x33    /* Remote machine not listening */
  240. #define ERROR_34            0x34    /* Duplicate name on network */
  241. #define ERROR_35            0x35    /* Network name not found */
  242. #define ERROR_36            0x36    /* Network busy */
  243. #define ERROR_37            0x37    /* Device no longer exists on network */
  244. #define ERROR_38            0x38    /* NetBIOS command limit exceeded */
  245. #define ERROR_39            0x39    /* Error in network adapter hardware */
  246. #define ERROR_3A            0x3A    /* Incorrect response from network */
  247. #define ERROR_3B            0x3B    /* Unexpected network error */
  248. #define ERROR_3C            0x3C    /* Remote adapter incompatible */
  249. #define ERROR_3D            0x3D    /* Print queue full */
  250. #define ERROR_3E            0x3E    /* Not enough room for print file */
  251. #define ERROR_3F            0x3F    /* Print file was deleted */
  252. #define ERROR_40            0x40    /* Network name deleted */
  253. #define ERROR_41            0x41    /* Network access denied */
  254. #define ERROR_42            0x42    /* Incorrect network device type */
  255. #define ERROR_43            0x43    /* Network name not found */
  256. #define ERROR_44            0x44    /* Network name limit exceeded */
  257. #define ERROR_45            0x45    /* NetBIOS session limit exceeded */
  258. #define ERROR_46            0x46    /* Temporary pause */
  259. #define ERROR_47            0x47    /* Network request not accepted */
  260. #define ERROR_48            0x48    /* Print or disk redirection paused */
  261. #define ERROR_50            0x50    /* File already exists */
  262. #define ERROR_51            0x51    /* Reserved */
  263. #define ERROR_52            0x52    /* Cannot make directory */
  264. #define ERROR_53            0x53    /* Fail on Int 24H (critical error) */
  265. #define ERROR_54            0x54    /* Too many redirections */
  266. #define ERROR_55            0x55    /* Duplicate redirection */
  267. #define ERROR_56            0x56    /* Invalid password */
  268. #define ERROR_57            0x57    /* Invalid parameter */
  269. #define ERROR_58            0x58    /* Net write fault */
  270.  
  271. #ifdef DEBUG
  272.         BOOL    fDebug;
  273.         BOOL    fDontCopy;
  274.         BOOL    __f;
  275.         extern FAR _Assert();
  276.         #define AssertF(exp) ( (exp) ? 0 : _Assert(__FILE__,__LINE__) )
  277.         #define AssertE(exp) ((__f=(exp)),AssertF(__f),__f)
  278. #else
  279.         #define AssertF(exp) 0
  280.         #define AssertE(exp) (exp)
  281. #endif
  282.